<template>
  <div>
    <div class="table">
      <el-table :data="list" stripe @selection-change="handleSelectionChange" :cell-style="{ 'text-align': 'center' }"
        border>
        <el-table-column align="center" prop="id" label="全选" type="selection"></el-table-column>
        <el-table-column align="center" prop="id" label="编号"></el-table-column>
        <el-table-column align="center" prop="name" label="品牌名称">
        </el-table-column>
        <el-table-column align="center" prop="firstLetter" label="品牌首字母">
        </el-table-column>
        <el-table-column align="center" prop="sort" label="排序">
        </el-table-column>
        <el-table-column align="center" prop="factoryStatus" label="品牌制造商" width="140">
          <template #default="scope">
            <el-switch v-model="scope.row.factoryStatus" :active-value="0" :inactive-value="1" />
          </template>
        </el-table-column>
        <el-table-column align="center" prop="showStatus" label="是否显示">
          <template #default="scope">
            <el-switch v-model="scope.row.showStatus" :active-value="0" :inactive-value="1" />
          </template>
        </el-table-column>
        <el-table-column align="center" prop="createTime" label="相关" width="200px">
          <template #default="scope">
            <div style="display: flex">
              <div style="margin-right: 10px">
                <span>商品：</span>
                <el-button type="primary" link>{{ 100 }}</el-button>
              </div>
              <div style="margin-right: 10px">
                <span>评价：</span>
                <el-button type="primary" link>{{ 100 }}</el-button>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="status" label="操作" width="150px">
          <template #default="scope">
            <div style="display: flex">
              <div style="margin-right: 10px">
                <el-button size="small" type="default" @click="edit(scope.row.id)">编辑</el-button>
              </div>
              <div>
                <el-button size="small" type="danger">删除</el-button>
              </div>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <div class="pagination">
        <!-- 批量操作 -->
        <div style="margin-top: 10px;">
          <el-select v-model="updateTable" placeholder="全部" size="large">
            <el-option v-for="(item, index) in updateOption" :key="item.txt" :value="item.txt"
              @click="updatefn(index)" />
          </el-select>
          <el-button type="primary" style="margin-left: 20px" @click="confirm">确定</el-button>
        </div>
        <el-pagination :page-sizes="[5, 10, 50, 100]" :default-page-size="5"
          layout="total, sizes, prev, pager, next, jumper" :total="paginateData.total" background
          @size-change="handleSizeChange" @current-change="handleCurrentChange" />
      </div>
    </div>
  </div>
</template>
  
<script setup lang='ts'>
import Add from '@/components/addlist/add.vue'
import { useTable } from '@/hook/table';
import { nextTick, reactive, ref, watch } from 'vue';
import * as http from '@/request/api'
import { useRouter, useRoute } from 'vue-router'

const router = useRouter()
const route = useRoute()
const keyword = ref('')
const updateTable = ref('')
let params = reactive<BrandList>({
  pageSize: 5,
  keyword: keyword.value
})
const updateOption = reactive([
  { http: http.product.ProductUpdatePublishStatus, txt: '显示品牌', label: 'publishStatus', value: 1 },
  { http: http.product.ProductUpdatePublishStatus, txt: '隐藏品牌', label: 'publishStatus', value: 0 },
])
let { list, paginateData, handleSizeChange, getData, handleCurrentChange } = useTable(http.product.BrandList, params)

function handleSelectionChange() { }


// 查看下级
async function nextStep(id: number) {
  params.parentId = id
  await router.push(`/pms/productCate?parentId=${id}`)
  getData()
}

// 选择批量操作类型
function updatefn(index: number) { }

// 编辑
function edit(id: number) {
  router.push(`/pms/updateProductCate?id=${id}`)
}

// 确定
async function confirm() { }
</script>
  
<style scoped>
.el-table__row {
  height: 60px;
}

.pagination {
  height: 40px;
  margin: 10px;
  padding-bottom: 10px;
  /* float: right; */
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>